package com.tencent.miniproject.utils;

import android.Manifest;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.pm.PackageManager;
import android.location.Location;
import android.location.LocationManager;
import android.support.v4.app.ActivityCompat;
import android.util.Log;

public class PositionUtil {

    private static String TAG = "positionUtil";

    /**
     * 主动获取Location，通过以下方法获取到的是最后一次定位信息。
     * 注意：Location location=new Location(LocationManager.GPS_PROVIDER)方式获取的location的各个参数值都是为0。
     */
    @SuppressLint("MissingPermission")
    public static void getLocation(Context context) {
//        LocationManager locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
//        Location location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
//        location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
//        Log.i(TAG, "纬度：" + location.getLatitude());
//        Log.i(TAG, "经度：" + location.getLongitude());
//        Log.i(TAG, "海拔：" + location.getAltitude());
//        Log.i(TAG, "时间：" + location.getTime());


    }

}
